package com.mdxl.four.controller;

import com.alibaba.fastjson.JSONObject;
import com.mongodb.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Collection;

@Controller
@RequestMapping(value = "/four")
public class FourController {
    @Autowired
    MongoClient mongoClient;
    //该client获取的集合Collection,然后根据特定方法，和first包下的封装一样
    @RequestMapping(value = "/get",method = RequestMethod.GET)
    @ResponseBody
    public void get(){
        DB db =mongoClient.getDB("springboot-db");
        DBCollection collection =db.getCollection("adminEntity");
        DBObject dbObject =new BasicDBObject();
        DBCursor jsonObject =collection.find(dbObject);
        //接下来根据collection 对集合的数据CRUD
    }

}
